package com.wl4837;

// 叶子组件 - 文件
class File implements FileSystemComponent {
    private final String name;

    public File(String name) {
        this.name = name;
    }

    @Override
    public void display(String indent) {
        System.out.println(indent + "📄 " + name);
    }

    // 叶子节点不支持以下操作
    @Override
    public void add(FileSystemComponent component) {
        throw new UnsupportedOperationException("文件不支持此操作");
    }

    @Override
    public void remove(FileSystemComponent component) {
        throw new UnsupportedOperationException("文件不支持此操作");
    }

    @Override
    public FileSystemComponent getChild(int index) {
        throw new UnsupportedOperationException("文件不支持此操作");
    }
}
